﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>系统消息</title>
</head>
<body>
    <div class="rightbar mt10">
        <ul class="tittab">
            <li class="tcurrent">系统消息</li>
        </ul>
        <div class="action-bar mt10">
            <p class="fd-left">
                <input name="cbAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="###"
                    onclick="DeleteListMsg();" class="wh01 h17">删除</a></span> <span class="ml30 fd-left">
                        <select name="sel_status" id="sel_status" onchange="setUrl()">
                            <option value="">消息状态</option>
                            <option value="0">未阅读</option>
                            <option value="1">已阅读</option>
                        </select>
                        <select name="sel_type" id ="sel_type" onchange="setUrl();">
                                <option value="">消息类型</option>
                                <option value="1">注册消息</option>
                                <option value="2,3">产品消息</option>
                                <option value="4,5">采购消息</option>
                                <option value="6">招聘消息</option>
                                <option value="7,8">竞价消息</option>
                                <option value="9,10">诚信消息</option>
                                <option value="14">短信消息</option>
                                <option value="15">建议消息</option>
                                <option value="16">推荐消息</option>
                        </select>
                        <input type="checkbox" id="cbx_time" class="mt03 none ml10 mr5" onclick="setUrl()" <%=(MsgTime=="1")?"checked ='checked'":"" %> />三个月以上的留言
                    </span>
            </p>
            <p class="fd-right">
                共 <b>
                    <%=RecordCount%></b> 封 <b class="red1">
                        <%=NotReadCount %></b> 封未读</p>
        </div>
        <div class="fd-clear"></div>
        <div class="msglists" id="msglists">
             @foreach (var single in @Model.Rows)
             {
                    <dl class="">
                        <dt>
                            <input type="checkbox" name="cbItem" value="<%# Eval("Id") %>" />
                        </dt>
                        <dd class="msgico">
                            <img src=""../images/msgimg"+@single["IsReader"]+".jpg"%>" />
                            <p>
                                @single["IsReader"].ToString()=="1"?"已阅读":"未阅读"</p>
                        </dd>
                        <dd class="msgcon">
                            <div class="red1">
                                @SYH.Public.BLL.Public_Messages.GetSystemMsgTitle((Int32)single["TypeId"])<span class="gray ml10 mr10">@single["CreateTime"]</span></div>
                            <div class="cur-p">
                                @single["Content"]
                            </div>
                        </dd>
                        <dd id="closeTip" class="close" style="display: none;">
                            <a href="###" title="删除" onclick="DeleteOneMsg(@single["Id"]);"></a>
                        </dd>
                    </dl>
             }
             @if (@Model.Rows.Count == 0)
             {
            <p style="padding: 50px 0 50px 280px;">
                <img src="../../images/no-data.gif" /></p>
             }
        </div>
        <div class="action-bar mt10 border-none">
            <p class="fd-left">
                <input name="cbAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="###"
                    onclick="DeleteListMsg();" class="wh01 h17">删除</a></span>
            </p>
            <p class="fd-right">
              
            </p>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#sel_status").val('@ViewBag.MsgStatus');
            $("#sel_type").val('@ViewBag.MsgType');
            $("input[name='cbAll']").click(function () {
                $("input[name='cbItem']").attr("checked", this.checked);
            });
        });
        //鼠标经过显示背景颜色和关闭按钮
        $(function(){
        $("#msglists>dl").hover(
        function(){
          $(this).children("dd.close").show();
          $(this).addClass("hover");
        },
        function(){
          $(this).children("dd.close").hide();
          $(this).removeClass("hover");
        })
})

        //删除一条信息
        function DeleteOneMsg(obj){
            var id = obj + ",";
            jQuery.dialogHelper.confirm('您确定要删除吗？', 'DeleteOneExec(\'' + id + '\')');
        }
        function DeleteOneExec(id){
        $.ajax({
                        type: "POST",
                        url: "/User/Message/DeleteList",
                        dataType: "text",
                        data: "id=" + id + "&type=DeleteList" + "&m=" + Math.random(),
                        success: function (msg) {
                            if (msg.indexOf("成功") != -1) {
                                jQuery.dialogHelper.alert("操作成功！", "success", "okSuccess");
                            }
                            else{
                                jQuery.dialogHelper.alert("操作失败！", "alert");
                            }
                        },
                        error: function () {
                            jQuery.dialogHelper.alert("网络忙，请稍后再试！", "alert");
                        }
                    });
        }
        //批量删除信息
        function DeleteListMsg() {
            var idList = "";
            $("input[name='cbItem']:checked").each(function () {
                idList += $(this).val() + ",";
            });
            if (idList == "") {
                jQuery.dialogHelper.alert("请先选择要删除的信息，然后点击删除！", "alert");
            }
            else {
            jQuery.dialogHelper.confirm('您确定要删除吗？', 'DeleteListExec(\'' + idList + '\')');;
            }
        }
        function DeleteListExec(idList){
        $.ajax({
                        type: "POST",
                        url: "/User/Message/DeleteList",
                        dataType: "text",
                        data: "id=" + idList + "&type=DeleteList" + "&m=" + Math.random(),
                        success: function (msg) {
                            if (msg.indexOf("成功") != -1) {
                                jQuery.dialogHelper.alert("操作成功！", "success", "okSuccess");
                            }
                            else{
                                jQuery.dialogHelper.alert("操作失败！", "alert");
                            }
                        },
                        error: function () {
                            jQuery.dialogHelper.alert("网络忙，请稍后再试！", "alert");
                        }
                    });
        }
        //删除成功
        function okSuccess() {
            $.dialogHelper.close();
            location.reload();
        }
       
    </script>
</body>
</html>
